package com.power.sifa.std.dao;

import com.power.sifa.std.model.Std_admuser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;

/**
 * 行政管理单位关联赣政通人员表 持久层(hibernate)
 */

public interface Std_admuserDao extends JpaRepository<Std_admuser, Serializable>, JpaSpecificationExecutor<Std_admuser>, Repository<Std_admuser, Serializable>, Std_admuserDaoCustom<Std_admuser, Serializable> {

   @Modifying
   @Transactional
   @Query("delete  from Std_admuser s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);

   @Query("select count (*) from Std_admuser  s where s.mobile = :mobile")
   int countByMobileAndAdmunit(@Param("mobile")String mobile);

   @Query(" from Std_admuser s where  s.admunitid = :admId ")
   List<Std_admuser> queryByAdmId(@Param("admId") String admId);

   @Query(" from Std_admuser s where  s.admunitid = :admId and s.mobile = :mobile")
   List<Std_admuser> queryByAdmIdAndMobile (@Param("admId") String admId, @Param("mobile") String mobile);
}
